package com.tc.zookeeper.curator;

import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent;
import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener;

public abstract class EnhancedChildrenAddRemoveListener implements PathChildrenCacheListener {

	@Override
	public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
		addRemoveProcess(client, event);
	}

	public void addRemoveProcess(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
		switch (event.getType()) {
		case CHILD_ADDED:
		case CHILD_REMOVED: {
			childEnhancedEvent((EnhancedCuratorFramework) client, event);
			break;
		}

		default:
			break;
		}
	}

	public abstract void childEnhancedEvent(EnhancedCuratorFramework client, PathChildrenCacheEvent event)
			throws Exception;

}
